﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TeamDoer.Models.LogOnModel>" %>
<%@ Import Namespace="TeamDoer" %>

<asp:Content ID="loginTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Log On
</asp:Content>

<asp:Content ID="loginContent" ContentPlaceHolderID="MainContent" runat="server">

    <% using (Html.BeginForm()) { %>
        <%: Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.") %>
        <div>
            <fieldset>
                <legend>Log on</legend>

				<div style="float:left;border-right:1px solid silver;padding-right:30px;">
                	<div class="editor-label">
						<%: Html.LabelFor(m => m.UserName) %>
					</div>
					<div class="editor-field">
						<%: Html.TextBoxFor(m => m.UserName) %>
						<%: Html.ValidationMessageFor(m => m.UserName) %>
					</div>
                
					<div class="editor-label">
						<%: Html.LabelFor(m => m.Password) %>
					</div>
					<div class="editor-field">
						<%: Html.PasswordFor(m => m.Password) %>
						<%: Html.ValidationMessageFor(m => m.Password) %>
					</div>
                
					<div class="editor-label">
						<%: Html.CheckBoxFor(m => m.RememberMe) %>
						<%: Html.LabelFor(m => m.RememberMe) %>
					</div>
                
					<input type="submit" value="Log On" />
				</div>
				<div style="margin-left:20px;float:left;padding-top:30px;">
					<a href="<%: Url.Action("TwitterLogin", "Account") %>" title="Sign-in with twitter"><img src="http://si0.twimg.com/images/dev/buttons/sign-in-with-twitter-l.png" /></a>
					<br /><br />
					<fb:login-button perms="email" onlogin="document.location.href = 'FacebookLogin'">Login with Facebook</fb:login-button>



					<br /><br />or <%: Html.ActionLink("Register", "Register") %>.
				</div>
            </fieldset>
        </div>
    <% } %>

	<div id="fb-root"></div>
	<script type="text/javascript">
		window.fbAsyncInit = function () {
			FB.init({ appId: '<%= Model.FacebookAppID %>', status: true, cookie: true,
				xfbml: true
			});
		};
		(function () {
			var e = document.createElement('script'); e.async = true;
			e.src = document.location.protocol +
			'//connect.facebook.net/en_US/all.js';
			document.getElementById('fb-root').appendChild(e);
		} ());

		function FbLogin() {
			FB.login(function (response) {
				if (response.session) {
					if (response.perms) {
						// user is logged in and granted some permissions.
						// perms is a comma separated list of granted permissions
						document.location.href = 'FacebookLogin';
					} else {
						// user is logged in, but did not grant any permissions
					}
				} else {
					// user is not logged in
				}
			}, { perms: 'email' });
		}
	</script>
</asp:Content>
